package com.hanhanxiaochong.zhongxiangchuanmei.util.recyclerview;

import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

/**
 * Created by RockPhoenix on 2018/8/28.
 */

public class MyRecyclerView extends RecyclerView {

    private final String TAG = MyRecyclerView.class.getSimpleName();
    private Callback callback;

    public MyRecyclerView(Context context) {
        super(context);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public MyRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent e) {
        Log.i(TAG, "onInterceptTouchEvent: " + e.getRawY() + "," + getTop());
        if (callback != null) {
            callback.moveEvent();
        }
        return super.onInterceptTouchEvent(e);
    }

    public void setCallback(Callback callback) {
        this.callback = callback;
    }

    public interface Callback {
        void moveEvent();
    }
}
